package com.ireadyit.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ireadyit.domain.Ticket;
import com.ireadyit.mapper.TicketMapper;
import com.ireadyit.service.ITicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 原浩伟
 * @description desc
 * @date 2021-05-14 9:51
 */
@Service
public class TicketServiceImpl extends ServiceImpl<TicketMapper, Ticket> implements ITicketService {

    @Autowired
    private TicketMapper ticketMapper;

    /**
     * @param page
     * @return com.baomidou.mybatisplus.extension.plugins.pagination.Page
     * @description MybatisPlus分页查询车票信息
     * @author 原浩伟
     * @date 2021-05-14 15:24
     */
    @Override
    public Page findTicketPage(Page page) {
//        PageHelper.startPage((int) page.getCurrent(), (int) page.getSize());
        return baseMapper.selectPage(page, null);
    }

    /**
     * @description Mybatis分页查询车票信息
     * @param page
     * @return com.github.pagehelper.PageInfo<com.ireadyit.domain.Ticket>
     * @author 原浩伟
     * @date 2021-05-14 15:31
     */
    @Override
    public PageInfo<Ticket> findTicketPageUseMybatis(Page page) {
        PageHelper.startPage((int) page.getCurrent(), (int) page.getSize());
        List<Ticket> list = ticketMapper.queryTicketAll();
        PageInfo<Ticket> pageInfo = new PageInfo<Ticket>(list);
        return pageInfo;
    }


}
